﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Diagnostics;

namespace Tos2Google
{
    public partial class AutoLoginDataForm : Form
    {
        public static bool EditAutoLoginData(AutoLogin autoLogin)
        {
            AutoLogin tmp = new AutoLogin();
            tmp.GetPropsFrom(autoLogin);
            AutoLoginDataForm dlg = new AutoLoginDataForm(tmp);
            dlg.ShowDialog();
            if (dlg.DialogResult == DialogResult.OK)
            {
                autoLogin.GetPropsFrom(tmp);
                return true;
            }
            return false;
        }

        public AutoLoginDataForm(AutoLogin autoLogin)
        {
            InitializeComponent();
            try
            {
                propertyGrid1.SelectedObject = autoLogin;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                // check string lengths?
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                return;
            }

            Close();
            DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
            DialogResult = DialogResult.Cancel;
        }
    }
}
